/**
 * 认证设置
 * @param flag
 * @param handleType
 */
function settingAuthenticator(layerType){
	var url = "/user/securityCommonLayer.do?random="+Math.round(Math.random()*100);
	var param = {layerType:layerType};
	jQuery("#securityLayer").load(url,param,function (data){
		var layerCode = document.getElementById("layerCode").value;
		var bindType = document.getElementById("bindType").value;
		var authLogin = document.getElementById("authLogin").value;
		var authTrade = document.getElementById("authTrade").value;
		if("01" == layerCode){
			openAuthenticatorLayer();
			//登录密码修改
			preLoginPasswordModify();
		}else if("02" == layerCode){
			openAuthenticatorLayer();
			//资金密码设置
			preMoneyPassword();
		}else if("03" == layerCode){
			openAuthenticatorLayer();
			//资金密码修改
			preMoneyPasswordModify();
		}else if("04" == layerCode){
			openAuthenticatorLayer();
			//手机绑定
			preBindPhone();
		}else if("05" == layerCode){
			openAuthenticatorLayer();
			//手机绑定修改
			preBindPhoneModity();
		}else if("06" == layerCode){
			openAuthenticatorLayer();
			//谷歌绑定 
			preBindGoogle();
		}else if("07" == layerCode){
			openAuthenticatorLayer();
			//密钥查看（谷歌已绑定） 
			preBindGoogleViewer();
		}else if("08" == layerCode){
			openAuthenticatorLayer();
			//邮箱绑定
			preBindEmail();
		}else if("09" == layerCode){
			openAuthenticatorLayer();
			//资金交易密码免输
			preMoneyPasswordNotEnter();
		}else if("10" == layerCode || "11" == layerCode ){
			//用户登录绑定谷歌（开/关）
			changeValidateCode(1,1,authLogin,bindType);
		}else if("12" == layerCode || "13" == layerCode){
			//短信验证绑定（开/关）
			changeValidateCode(2,2,authTrade,bindType);
		}else if("14" == layerCode || "15" == layerCode){
			//谷歌验证绑定（开/关）
			changeValidateCode(1,2,authTrade,bindType);
		}else if("16" == layerCode){
			//资金免密码输入（每次输入）
			moneyNotEnter(2);
		}else if("17" == layerCode){
			//资金免密码输入（2小时输入）
			moneyNotEnter(1);
		}else if("18" == layerCode){
			//资金免密码输入（不输入）
			moneyNotEnter(0);
			if(document.getElementById("refreshSingal")!=null){
				document.getElementById("refreshSingal").value = 1;
			}
		}else if("19" == layerCode){
			openAuthenticatorLayer();
			//子账户绑定邮箱
			document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
		}else if("20" == layerCode){
			openAuthenticatorLayer();
			//绑定微信
			weixinLoginViewer();
			document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
		}else if("21" == layerCode){
			//绑定微信
			openAuthenticatorLayer();
//			weixinTradeClose();
			document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
		}else if("22" == layerCode){
			//设置防钓鱼码
			openAuthenticatorLayer();
			document.getElementById("layerTitle").innerHTML=get$("antiphishing1");
		}else if("23" == layerCode){
			//修改防钓鱼码
			openAuthenticatorLayer();
			document.getElementById("layerTitle").innerHTML=get$("antiphishing2");
		}else if("24" == layerCode){
			//修改邮箱
			openAuthenticatorLayer();
			document.getElementById("layerTitle").innerHTML=get$("userindexjs53");
		}else if("25" == layerCode){
			//修改邮箱
			openAuthenticatorLayer();
			//谷歌绑定
			preBindGoogle();
		}
		
	});
}
function submitNewEmail(){
	var phoneCode = "";
	var totpCode = jQuery("#newEmailTotpCode").val();
	var regu = /^[0-9]{6}$/;
    var re = new RegExp(regu);
    var email = "";
    email = document.getElementById("newEmail").value;
    if(!checkEmail(email)){
    	document.getElementById("newEmailTips").innerHTML=get$("coincommonjs26");
    	return ;
    }else{
		document.getElementById("newEmailTips").innerHTML="";
	}
	
	if(document.getElementById("newEmailPhoneCode") != null){
		phoneCode = trim(document.getElementById("newEmailPhoneCode").value);
		if (!re.test(phoneCode)) {
			document.getElementById("newEmailPhoneCodeTips").style.display = "";
			document.getElementById("newEmailPhoneCodeTips").innerHTML=userindexjs4;
			return;
		}else{
			document.getElementById("newEmailPhoneCodeTips").innerHTML="&nbsp;";
			document.getElementById("newEmailPhoneCodeTips").style.display = "none";
		}
	}
	if(document.getElementById("newEmailTotpCode") != null){
		totpCode = trim(document.getElementById("newEmailTotpCode").value);
		if (!re.test(totpCode)) {
			document.getElementById("newEmailTotpCodeTips").innerHTML=userindexjs5;
			return;
		}else{
			document.getElementById("newEmailTotpCodeTips").innerHTML="&nbsp;";
		}
	}
	
	var url = "/user/submitNewEmail.do?random="+Math.round(Math.random()*100);
	var param={email:email,phoneCode:phoneCode,totpCode:totpCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode==0){
				window.location.href = "/user/resendEmailConfirm.do?type=1";
			}else if(result.resultCode == -1){
				document.getElementById("newEmailTips").innerHTML=get$("coincommonjs26");
			}else if(result.resultCode == -2){
				document.getElementById("newEmailTips").innerHTML=get$("userindexjs19");
			}else if(result.resultCode == -3){
				document.getElementById("newEmailTips").innerHTML="绑定失败";
			}else if(result.resultCode == -11){
				document.getElementById("newEmailTotpCodeTips").innerHTML=blindphonejs3;
			}else if(result.resultCode == -12){
				 document.getElementById("newEmailPhoneCodeTips").style.display = "";
				 document.getElementById("newEmailPhoneCodeTips").innerHTML=blindphonejs2;
			}else if(result.resultCode == -8){
				if(result.errorNum == 0){
					document.getElementById("newEmailTotpCodeTips").innerHTML=exceededgooglecodeattempts;
				}else{
					document.getElementById("newEmailTotpCodeTips").innerHTML=googlecodeincorrect+youhave+result.errorNum+chancesleft;
					document.getElementById("newEmailTotpCode").value = "";
				}
			}else if(result.resultCode == -9){
				if(result.errorNum == 0){
					document.getElementById("newEmailPhoneCodeTips").style.display = "";
					document.getElementById("newEmailPhoneCodeTips").innerHTML=smscodewrongmuchtime;
				}else{
					document.getElementById("newEmailPhoneCodeTips").style.display = "";
					document.getElementById("newEmailPhoneCodeTips").innerHTML=smsisincorrect+youhave+result.errorNum+chancesleft;
					document.getElementById("newEmailPhoneCode").value = "";
				}
			}
		}
		
	});
	
}
function tipsNewEmail(obj){
	if(!checkEmail(obj.value)){
		document.getElementById("newEmailTips").innerHTML=get$("coincommonjs26");
	}else{
		document.getElementById("newEmailTips").innerHTML="";
	}
}

//登录密码修改
function preLoginPasswordModify(){
	displaySoftKeyboard();
	document.getElementById("pwdType").value=0;
	document.getElementById("messageType").value = 12;
	document.getElementById("layerTitle").innerHTML=passwordjs1;
	document.getElementById("originPwdTitle").innerHTML=passwordjs2;
	document.getElementById("newPwdTitle").innerHTML=passwordjs3;
	document.getElementById("reNewTitle").innerHTML=passwordjs4;
	document.getElementById("originPwd").focus();
}

//登录密码修改提交
function submitLoginPasswordModify(perType){
	//调用user/password.js
	submitPwdForm(perType);
}

//资金密码设置
function preMoneyPassword(){
	displaySoftKeyboard();
	document.getElementById("pwdType").value=2;
	document.getElementById("messageType").value = 4;
	document.getElementById("layerTitle").innerHTML=passwordjs5;
	document.getElementById("newPwdTitle").innerHTML=passwordjs7;
	document.getElementById("reNewTitle").innerHTML=get$("passwordjs8new");
	document.getElementById("originPwd").focus();
}

//资金密码设置提交
function submitMoneyPassword(perType){
	submitLoginPasswordModify(perType);
}

//资金密码修改
function preMoneyPasswordModify(){
	displaySoftKeyboard();
	document.getElementById("pwdType").value=1;
	if(document.getElementById("isEmptyPhone") !=null && document.getElementById("isEmptyPhone").value==1&&document.getElementById("isEmptyAuth") !=null && document.getElementById("isEmptyAuth").value==1){
		bindAuth();
		return;
	}
	document.getElementById("messageType").value = 4;
	document.getElementById("layerTitle").innerHTML=passwordjs5;
	document.getElementById("originPwdTitle").innerHTML=passwordjs6;
	document.getElementById("newPwdTitle").innerHTML=passwordjs7;
	document.getElementById("reNewTitle").innerHTML=get$("passwordjs8new");
	document.getElementById("newPwd").focus();
}

//资金密码修改提交
function submitMoneyPasswordModify(){
	submitLoginPasswordModify();
}

//手机绑定设置
function preBindPhone(){
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
}

//手机绑定设置提交
function submitBindPhone(){
	//调用user/bindPhone.js
	submitValidatePhoneForm();
}

//手机绑定修改
function preBindPhoneModity(){
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
}

//手机绑定修改格式验证
function checkPhoneBlur(){
	var mobile = document.getElementById("updatePhoneNumber").value;
	if(!checkMobile(mobile)){
		document.getElementById("updatePhoneinfoTips").innerHTML = blindphonejs31;
	}else{
		document.getElementById("updatePhoneinfoTips").innerHTML = blindphonejs31;
	}
	document.getElementById("updatePhoneinfoTips").innerHTML = " ";
}

//手机绑定修改提交
function submitBindPhoneModity(){
	//调用user/bindPhone.js
	submitUpdatePhoneForm();
}

//谷歌绑定 
function preBindGoogle(){
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
	var qecode = document.getElementById("qecode").value;
	var qekey = document.getElementById("qekey").value;
	if(navigator.userAgent.indexOf("MSIE")>0) { 
		jQuery('#qrcode').qrcode({text:qecode,width:"150",height:"150",render:"table"}); 
	} else{
		jQuery('#qrcode').qrcode({text:qecode,width:"150",height:"150"}); 
	}
	document.getElementById("totpKey").value = qekey;
	document.getElementById("bindAuthenticatorValidateTotpCode").focus();
}

//谷歌绑定提交
function submitBindGoogle(){
    var siteFlag = document.getElementById("footsetFlag").value;

    if(document.getElementById("changeTotpCodeTips") != null){
		document.getElementById("changeTotpCodeTips").innerHTML="";
	}
	document.getElementById("googleInfoTips").innerHTML="";

	if(document.getElementById("bindAuthenticatorValidateTotpCode") == null){
		return;
	}

	var desc='';
	var totpCode = 0;
	if(document.getElementById("totpCodeLi")!= null){
		totpCode = document.getElementById("changeTotpCode").value;
		if(totpCode.indexOf(" ")>-1 || totpCode.length !=6){
			desc=blindphonejs3;
		}
		if(desc!=""){
			document.getElementById("changeTotpCodeTips").innerHTML="";
			document.getElementById("changeTotpCodeTips").innerHTML=desc;
			return;
		}
	}

	var code = document.getElementById("bindAuthenticatorValidateTotpCode").value;
	var phoneCode = 0;

	if( document.getElementById("bindAuthenticatorPhoneCode") != null ){
		phoneCode = document.getElementById("bindAuthenticatorPhoneCode").value;
		if(phoneCode.indexOf(" ")>-1 || phoneCode.length !=6){
			desc=blindphonejs2;	
		}
	}
	if(code.indexOf(" ")>-1 || code.length !=6){
		desc=blindphonejs3;	
	}
	if(desc!=""){
		document.getElementById("googleInfoTips").innerHTML="";
		document.getElementById("googleInfoTips").innerHTML=desc;
		return;
	}else{
		document.getElementById("googleInfoTips").innerHTML="&nbsp;";
	}
	var layerCode = document.getElementById("layerCode").value;

	var url = "/user/validateAuthenticator.do?random="+Math.round(Math.random()*100);
	var param={code:code,phoneCode:phoneCode,totpCode:totpCode,layerCode:layerCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode == 0){
				closeAuthenticatorLayerWithNoRefresh();
				var callback={okBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";},noBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";}};
				if(siteFlag==2){
                    okcoinAlert(get$("blindphonejs14com"),null,callback);
                }else{
                    okcoinAlert(get$("blindphonejs14cn"),null,callback);
                }
			 }else if(result.resultCode == -11){
				 document.getElementById("googleInfoTips").innerHTML=blindphonejs3;
			 }else if(result.resultCode == -12){
				 document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs2;
			 }else if(result.resultCode == -3){
				 if(result.errorNum == 0){
					 document.getElementById("googleInfoTips").innerHTML=blindphonejs11;
				 }else{
					 document.getElementById("googleInfoTips").innerHTML=blindphonejs12+youhave+result.errorNum+chancesleft;
					 document.getElementById("bindAuthenticatorValidateTotpCode").value = "";
				 }
			 }else if(result.resultCode == -9){
				 if(result.errorNum == 0){
					 document.getElementById("googleInfoTips").innerHTML=blindphonejs8;
				 }else{
					 document.getElementById("googleInfoTips").innerHTML=blindphonejs9+youhave+result.errorNum+chancesleft;
					 document.getElementById("bindAuthenticatorPhoneCode").value = "";
				 }
			 }else if(result.resultCode == -20){
				document.getElementById("googleInfoTips").innerHTML = googlecodebeenused;
			 }else if(result.resultCode == -4){
				document.getElementById("changeTotpCodeTips").innerHTML = blindphonejs3;
			 }else if(result.resultCode == -5){
				if(result.errorNum == 0){
					document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs11;
				}else{
					document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs12+youhave+result.errorNum+chancesleft;
					document.getElementById("changeTotpCode").value = "";
				}
			 }else if(result.resultCode == -6){
				document.getElementById("changeTotpCodeTips").innerHTML = googlecodebeenused;
			}else if(result.resultCode == -2){
				document.getElementById("googleInfoTips").innerHTML = blindphonejs44;
			}
		}
	});
}

//密钥查看（谷歌已绑定） 
function preBindGoogleViewer(){
	var authenticatorType = document.getElementById("authTrade").value;
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
	if(authenticatorType == 0){
		document.getElementById("changeAuthMsg").style.display="";
	}
	dialogBoxShadow(false);
	var isEmptyPhone = document.getElementById("isEmptyPhone").value; 
	if(isEmptyPhone == 0){
		if(document.getElementById("phoneCodeLi")!= null){
			document.getElementById("phoneCodeLi").style.display = "block";
		}
		if(document.getElementById("totpCodeLi")!= null){
			document.getElementById("totpCodeLi").style.display = "none";
		}
	}else{
		if(document.getElementById("phoneCodeLi")!= null){
			document.getElementById("phoneCodeLi").style.display = "none";
		}
		if(document.getElementById("totpCodeLi")!= null){
			document.getElementById("totpCodeLi").style.display = "block";
		}
	}
	if(document.getElementById("msgSpan") != null){
		document.getElementById("msgSpan").innerHTML = get$("viewgoogleauthenticatorkey");
	}
	if(document.getElementById("messageType") != null){
		document.getElementById("messageType").value = 8;
	}
}

//密钥查看（谷歌已绑定） 发送短信验证码
function securitySendMsg(){
	var type = document.getElementById("messageType").value;
	sendMsgCode2(type,"changeMsgCodeBtn");
}

//密钥查看（谷歌已绑定） 提交
function submitBindGoogleViewer(){
	var totpCode = 0;
	var phoneCode = 0;
	var desc='';
	var isEmptyPhone = document.getElementById("isEmptyPhone").value;
	if(isEmptyPhone == 1 && document.getElementById("totpCodeLi")!= null){
		totpCode = document.getElementById("changeTotpCode").value;
		if(totpCode.indexOf(" ")>-1 || totpCode.length !=6){
			desc=blindphonejs3;	
		}
		if(desc!=""){
			document.getElementById("changeTotpCodeTips").innerHTML="";
			document.getElementById("changeTotpCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("changeTotpCodeTips").innerHTML="&nbsp;";
		}
	}
	if(isEmptyPhone == 0 && document.getElementById("phoneCodeLi")!= null){
		phoneCode = document.getElementById("changePhoneCode").value;
		if(phoneCode.indexOf(" ")>-1 || phoneCode.length !=6){
			desc=blindphonejs2;	
		}
		if(desc!=""){
			document.getElementById("changePhoneCodeTips").innerHTML="";
			document.getElementById("changePhoneCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("changePhoneCodeTips").innerHTML="&nbsp;";
		}
	}
	var url = "/user/getGoogleTotpKey.do?random="+Math.round(Math.random()*100);
	var param={totpCode:totpCode,phoneCode:phoneCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			 if(result.resultCode == -11){
				 document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs3;
			 }else if(result.resultCode == -12){
				 document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs2;
			 }else if(result.resultCode == -8){
				 if(result.errorNum == 0){
					 document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs11;
				 }else{
					 document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs12+youhave+result.errorNum+chancesleft;
					 document.getElementById("changeTotpCode").value = "";
				 }
			 }else if(result.resultCode == -9){
				 if(result.errorNum == 0){
					 document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs8;
				 }else{
					 document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs9+youhave+result.errorNum+chancesleft;
					 document.getElementById("changePhoneCode").value = "";
				 }
			 }else if(result.resultCode == 0){
				if(result.resultCode == 0){
					waitingStation("submitBtn",insubmiting)
					dialogBoxShadow(false);
					document.getElementById("securityLayer").style.display = "block";
					document.getElementById("authfirst").style.display = "none";
					document.getElementById("authsecond").style.display = "block";
					addMoveEvent("dialog_title","dialog_content");
					if(navigator.userAgent.indexOf("MSIE")>0) { 
						jQuery('#qrcode').qrcode({text:result.qecode,width:"150",height:"150",render:"table"}); 
					} else{
						jQuery('#qrcode').qrcode({text:result.qecode,width:"150",height:"150"}); 
					}
					document.getElementById("totpKey").value = result.totpKey;
					document.getElementById("layerTitle").innerHTML = blindphonejs23;
					document.getElementById("msgSpan").innerHTML = "";
					document.getElementById("msgSpan2").innerHTML = "";
					document.getElementById("authsecond").style.textAlign = "center";
					document.getElementById("dialog_content").style.width =  "250px";
				}
			 }else if(result.resultCode == -20){
				 document.getElementById("changeTotpCodeTips").innerHTML=googlecodebeenused;
				 document.getElementById("changeTotpCode").value = "";
			 }
		}
	});
}

//邮箱绑定
function preBindEmail(){
	displaySoftKeyboard();
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
}

//邮箱绑定提交
function submitBindedEmail(){
	//调用user/index.js
	submitBindEmail();
}

//资金交易密码免输
function preMoneyPasswordNotEnter(){
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
}

//资金交易密码免输提交
function submitMoneyPasswordNotEnter(){
	//调用user/index.js
	configureSubmit();
}

//validateCodeType 1:谷歌 2:短信
//operationType 1:登录 2:提现
//type 1:手机 2:谷歌 3:全部开启
//bindType 1:手机 2:谷歌 3:全部绑定
function changeValidateCode(validateCodeType,operationType,type,bindType){
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
	if(document.getElementById("messageType") != null){
		document.getElementById("messageType").value = 10;
	}
	if(operationType == 2){
		if(type == 1 && validateCodeType == 1 ){//开启的谷歌 点谷歌 没有绑定手机
			okcoinAlert(blindphonejs25,null,null);
			return ;
		}
		if(type == 2 && validateCodeType == 2 ){//开启的短信 点短信 没有绑定谷歌
			okcoinAlert(blindphonejs26,null,null);
			return ;
		}
		if((bindType != 1 && bindType != 3)  && validateCodeType == 2){//未绑定手机开启手机
			okcoinAlert(blindphonejs27,null,null);
			return ;
		}
		if((bindType != 2 && bindType != 3)  && validateCodeType == 1){//未绑定谷歌开启谷歌
			okcoinAlert(blindphonejs45,null,null);
			return ;
		}
	}else if(operationType == 1){
		if(bindType != 2 && bindType != 3  ){//未绑定谷歌开启谷歌
			okcoinAlert(blindphonejs45,null,null);
			return ;
		}
	}
	openAuthenticatorLayer();
	if(document.getElementById("changeTotpCode")!= null){
		document.getElementById("changeTotpCode").value = "";
		document.getElementById("changeTotpCodeTips").innerHTML = "";
	}
	if(document.getElementById("changePhoneCode")!= null){
		document.getElementById("changePhoneCode").value = "";
		document.getElementById("changePhoneCodeTips").innerHTML = "";
	}
	document.getElementById("operationType").value = operationType;
	document.getElementById("validateCodeType").value = validateCodeType;
	if(validateCodeType == 1){
		if(document.getElementById("phoneCodeLi")!= null){
			document.getElementById("phoneCodeLi").style.display = "none";
		}
		if(document.getElementById("totpCodeLi")!= null){
			document.getElementById("totpCodeLi").style.display = "block";
		}
	}
	if(operationType == 2){
		if(validateCodeType == 1){
			if(document.getElementById("phoneCodeLi")!= null){
				document.getElementById("phoneCodeLi").style.display = "block";
			}
			if(document.getElementById("totpCodeLi")!= null){
				document.getElementById("totpCodeLi").style.display = "none";
			}
		}else if(validateCodeType == 2){
			if(document.getElementById("totpCodeLi")!= null){
				document.getElementById("totpCodeLi").style.display = "block";
			}
			if(document.getElementById("phoneCodeLi")!= null){
				if(type == 3){
					document.getElementById("phoneCodeLi").style.display = "block";
				}else{
					document.getElementById("phoneCodeLi").style.display = "none";
				}
			}
		}
	}
	
	var str ="";
	if(operationType == 1 ){
		str = blindphonejs28;
		if(document.getElementById("totpCodeLi")!= null){
			document.getElementById("totpCodeLi").style.display = "block";
		}
		if(document.getElementById("phoneCodeLi")!= null){
			document.getElementById("phoneCodeLi").style.display = "none";
		}
	}else{
		str = get$("changetwomodifyway");
	}
	if(document.getElementById("msgSpan") != null){
		document.getElementById("msgSpan").innerHTML = str;
	}
}

//开关
function submitChangeAuthForm(){
	var changeTotpCode = 0;
	var changePhoneCode = 0;
	var desc='';
	var operationType = document.getElementById("operationType").value;
	var validateCodeType = document.getElementById("validateCodeType").value;
	var regu = /^[0-9]{6}$/;
    var re = new RegExp(regu);
	if(document.getElementById("changeTotpCode")!= null &&( validateCodeType == 2 || operationType == 1)){
		changeTotpCode = document.getElementById("changeTotpCode").value;
		if (!re.test(changeTotpCode)) {
	    	desc=blindphonejs3;	
	    }
		if(desc!=""){
			document.getElementById("changeTotpCodeTips").innerHTML="";
			document.getElementById("changeTotpCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("changeTotpCodeTips").innerHTML="&nbsp;";
		}
	}
	if(document.getElementById("changePhoneCode")!= null  && operationType != 1 && document.getElementById("phoneCodeLi").style.display == "block"){
		changePhoneCode = document.getElementById("changePhoneCode").value;
	    if (!re.test(changePhoneCode)) {
	    	desc=blindphonejs2;	
	    }
		if(desc!=""){
			document.getElementById("changePhoneCodeTips").innerHTML="";
			document.getElementById("changePhoneCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("changePhoneCodeTips").innerHTML="&nbsp;";
		}
	}
	var url = "/user/changeValidateCode.do?random="+Math.round(Math.random()*100);
	var param={totpCode:changeTotpCode,phoneCode:changePhoneCode,operationType:operationType,validateCodeType:validateCodeType};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode == 0){
				waitingStation("submitBtn",insubmiting);
				if(document.getElementById("changeTotpCode")!= null){
					document.getElementById("changeTotpCode").value="";
				}
				if(document.getElementById("changePhoneCode")!= null){
					document.getElementById("changePhoneCode").value="";
				}
				closeAuthenticatorLayerWithNoRefresh();
				var callback={okBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";},noBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";}};
				okcoinAlert(blindphonejs18,null,callback);
			 }else if(result.resultCode == -2){
				 document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs3;
			 }else if(result.resultCode == -3){
				 document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs2;
			 }else if(result.resultCode == -4){
				 document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs19;
			 }else if(result.resultCode == -5 ){
				 document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs20;
			 }else if(result.resultCode == -6 ){
				 document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs21;
			 }else if(result.resultCode == -7){
				 document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs22;
			 }else if(result.resultCode == -8){
				 if(result.errorNum == 0){
					document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs11;
				}else{
					document.getElementById("changeTotpCodeTips").innerHTML=blindphonejs12+youhave+result.errorNum+chancesleft;
					document.getElementById("changeTotpCode").value = "";
				}
			 }else if(result.resultCode == -9){
				 if(result.errorNum == 0){
						document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs8;
				}else{
					document.getElementById("changePhoneCodeTips").innerHTML=blindphonejs9+youhave+result.errorNum+chancesleft;
					document.getElementById("changePhoneCode").value = "";
				}
			 }else if(result.resultCode == -11){
				 document.getElementById("changeTotpCodeTips").innerHTML=googlecodeformatincorrect;
			 }else if(result.resultCode == -12){
				 document.getElementById("changePhoneCodeTips").innerHTML=smscodeformatincorrect;
			 }else if(result.resultCode == -20){
				 document.getElementById("changeTotpCodeTips").innerHTML=googlecodebeenused;
			 }
		}
	});
}

/**
 * 显示软键盘
 */
function displaySoftKeyboard(){
	jQuery('#originPwd').keyboard({
		lang:'en',name:'7'
	});
	jQuery('#newPwd').keyboard({
		lang:'en',name:'8'
	});
	jQuery('#reNewPwd').keyboard({
		lang:'en',name:'9'
	});
	jQuery('#oncePwd').keyboard({
		lang:'en',name:'22'
	});
	jQuery('#twicePwd').keyboard({
		lang:'en',name:'23'
	});
	jQuery('#zjPwd').keyboard({
		lang:'en',name:'24'
	});
}

/**
 * 关闭弹层
 */
function openAuthenticatorLayer(){
	dialogBoxShadow(false);
	document.getElementById("securityLayer").style.display = "block";
	addMoveEvent("dialog_title","dialog_content");
}

/**
 * 关闭弹层
 */
function closeAuthenticatorLayer(){
	dialogBoxHidden();
	document.getElementById("securityLayer").style.display = "none";
	if(document.getElementById("refreshSingal")!=null&&document.getElementById("refreshSingal").value == 1){
		window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";
	}
}

/**
 * 关闭弹层(无刷新)
 */
function closeAuthenticatorLayerWithNoRefresh(){
	dialogBoxHidden();
	document.getElementById("securityLayer").style.display = "none";
}

/**
 * 密码强度验证
 */
function checkPasswordStrong(value,ojb){
	if(value == "" || document.getElementById(ojb) == null){
		return ;
	}
	var pwdflag = checkStrong(value);
	if(pwdflag <= 2){
		document.getElementById(ojb).innerHTML=passwordstrengthlow;
	}else if(pwdflag == 3){
		document.getElementById(ojb).innerHTML=passwordstrengthmedium;
	}else{
		document.getElementById(ojb).innerHTML="";
	}
}

/**
 * 密码强度验证
 */
function checkPasswordIsSame(ojb1,ojb2,tipsOjb){
	var password1 = document.getElementById(ojb1).value;
	var password2 = document.getElementById(ojb2).value;
	if(password1 != password2){
		document.getElementById(tipsOjb).innerHTML = coincommonjs38;
	}else{
		document.getElementById(tipsOjb).innerHTML = "";
	}
}

/**
 * 资金免输入
 */
function moneyNotEnter(currentSelectStatus){
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
	var status = document.getElementById("status").value;
	if(currentSelectStatus == status){
		return ;
	}
	//把当前选中的值保存起来
	document.getElementById("currentSelectStatus").value = currentSelectStatus;
	if(currentSelectStatus==0 && status!=0){
		openAuthenticatorLayer();
	}else{
		openMoney2HoursEnter();
	}
}

/**
 * 2小时输入
 */
function openMoney2HoursEnter(){
	var status = document.getElementById("currentSelectStatus").value;
	var callback1 = {okBack:function(){
		var param={status:status};
		var url = "/user/openTradePwd.do?random="+Math.round(Math.random()*100);
		jQuery.post(url,param,function(data){
			var result = eval('(' + data + ')');
			if(result!=null){
				if(result.resultCode == 0){
					closeAuthenticatorLayerWithNoRefresh();
					 var callback={okBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";},noBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";}};
						okcoinAlert(blindphonejs47,null,callback);
				 }
			}
		});
	},noBack:function(){
		window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";
	}};
	okcoinAlert(sureyoutoopenfundspassword,null,callback1);
		
}

/**
 * 资金免输入提交
 */
function submitMoneyNotEnter(){
	//调用user/index.js
	configureSubmit();
}


//微信绑定
function weixinLoginViewer(){
	document.getElementById("layerTitle").innerHTML=document.getElementById("keyTitle").value;
}
function weixinTradeClose(){
	var changeTotpCode = 0;
	var changePhoneCode = 0;
	var regu = /^[0-9]{6}$/;
    var re = new RegExp(regu);
    var desc = "";
	if(document.getElementById("weixinCloseTotpCode")!= null ){
		changeTotpCode = document.getElementById("weixinCloseTotpCode").value;
		if (!re.test(changeTotpCode)) {
	    	desc=blindphonejs3;	
	    }
		if(desc!=""){
			document.getElementById("weixinCloseTotpCodeTips").innerHTML="";
			document.getElementById("weixinCloseTotpCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("weixinCloseTotpCodeTips").innerHTML="&nbsp;";
		}
	}
	if(document.getElementById("weixinClosePhoneCode")!= null ){
		changePhoneCode = document.getElementById("weixinClosePhoneCode").value;
	    if (!re.test(changePhoneCode)) {
	    	desc=blindphonejs2;	
	    }
		if(desc!=""){
			document.getElementById("weixinClosePhoneCodeTips").innerHTML="";
			document.getElementById("weixinClosePhoneCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("weixinClosePhoneCodeTips").innerHTML="&nbsp;";
		}
	}
	var url = "/user/weixinTradeClose.do?random="+Math.round(Math.random()*100);
	var param={totpCode:changeTotpCode,phoneCode:changePhoneCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode == -11){
				 document.getElementById("weixinCloseTotpCodeTips").innerHTML=blindphonejs3;
			 }else if(result.resultCode == -12){
				 document.getElementById("weixinClosePhoneCodeTips").innerHTML=blindphonejs2;
			 }else if(result.resultCode == -8){
				 if(result.errorNum == 0){
					 document.getElementById("weixinCloseTotpCodeTips").innerHTML=exceededgooglecodeattempts;
				 }else{
					 document.getElementById("weixinCloseTotpCodeTips").innerHTML=googlecodeincorrect+youhave+result.errorNum+chancesleft;
					 document.getElementById("weixinCloseTotpCode").value = "";
				 }
			 }else if(result.resultCode == -9){
				 if(result.errorNum == 0){
					 document.getElementById("weixinClosePhoneCodeTips").innerHTML=smscodewrongmuchtime;
				 }else{
					 document.getElementById("weixinClosePhoneCodeTips").innerHTML=smsisincorrect+youhave+result.errorNum+chancesleft;
					 document.getElementById("weixinClosePhoneCode").value = "";
				 }
			 }else if(result.resultCode == 0){
				window.location.reload();
			 }else if(result.resultCode == -20){
				 document.getElementById("weixinCloseTotpCodeTips").innerHTML=googlecodebeenused;
				 document.getElementById("weixinCloseTotpCode").value = "";
			 }
		}
	});
	
}
//微信绑定 提交
function submitWeixinLoginViewer(){
	var changeTotpCode = 0;
	var changePhoneCode = 0;
	var regu = /^[0-9]{6}$/;
    var re = new RegExp(regu);
    var desc = "";
	if(document.getElementById("configureTotpCode")!= null ){
		changeTotpCode = document.getElementById("configureTotpCode").value;
		if (!re.test(changeTotpCode)) {
	    	desc=blindphonejs3;	
	    }
		if(desc!=""){
			document.getElementById("configureTotpCodeTips").innerHTML="";
			document.getElementById("configureTotpCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("configureTotpCodeTips").innerHTML="&nbsp;";
		}
	}
	if(document.getElementById("configurePhoneCode")!= null ){
		changePhoneCode = document.getElementById("configurePhoneCode").value;
	    if (!re.test(changePhoneCode)) {
	    	desc=blindphonejs2;	
	    }
		if(desc!=""){
			document.getElementById("configurePhoneCodeTips").innerHTML="";
			document.getElementById("configurePhoneCodeTips").innerHTML=desc;
			return;
		}else{
			document.getElementById("configurePhoneCodeTips").innerHTML="&nbsp;";
		}
	}
	var url = "/user/weixinLogin.do?random="+Math.round(Math.random()*100);
	var param={totpCode:changeTotpCode,phoneCode:changePhoneCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode == -11){
				 document.getElementById("configureTotpCodeTips").innerHTML=blindphonejs3;
			 }else if(result.resultCode == -12){
				 document.getElementById("configurePhoneCodeTips").innerHTML=blindphonejs2;
			 }else if(result.resultCode == -8){
				 if(result.errorNum == 0){
					 document.getElementById("configureTotpCodeTips").innerHTML=exceededgooglecodeattempts;
				 }else{
					 document.getElementById("configureTotpCodeTips").innerHTML=googlecodeincorrect+youhave+result.errorNum+chancesleft;
					 document.getElementById("configureTotpCode").value = "";
				 }
			 }else if(result.resultCode == -9){
				 if(result.errorNum == 0){
					 document.getElementById("configurePhoneCodeTips").innerHTML=smscodewrongmuchtime;
				 }else{
					 document.getElementById("configurePhoneCodeTips").innerHTML=smsisincorrect+youhave+result.errorNum+chancesleft;
					 document.getElementById("configurePhoneCode").value = "";
				 }
			 }else if(result.resultCode == 0){
				waitingStation("submitBtn",insubmiting);
				dialogBoxShadow(false);
				var screenHeight = document.documentElement.clientHeight;
				var screenWidth = document.documentElement.clientWidth;
				var leftDis=(screenWidth-600)/2;
				var topDis=(screenHeight-380)/2;
				document.getElementById("securityLayer").style.display = "block";
				document.getElementById("authfirst").style.display = "none";
				document.getElementById("authsecond").style.display = "block";
				addMoveEvent("dialog_title","dialog_content");
				if(navigator.userAgent.indexOf("MSIE")>0) {
					jQuery('#qrcode').qrcode({text:result.qecode,width:"250",height:"250",render:"table"}); 
				} else{
					jQuery('#qrcode').qrcode({text:result.qecode,width:"250",height:"250"}); 
				}
				document.getElementById("layerTitle").innerHTML = get$("weixinqrcode");
				document.getElementById("weixinmsgTitle").innerHTML = "";
				document.getElementById("dialog_body_wexin").style.paddingLeft = "15px";
				document.getElementById("authsecond").style.textAlign = "center";
//				document.getElementById("dialog_content").style.width =  "300px";
				document.getElementById("dialog_content").style.left =  leftDis+"px";
				document.getElementById("dialog_content").style.top =  topDis+"px";
				document.getElementById("dialog_content").style.margin =  "0px";
			 }else if(result.resultCode == -20){
				 document.getElementById("configureTotpCodeTips").innerHTML=googlecodebeenused;
				 document.getElementById("configureTotpCode").value = "";
			 }
		}
	});
}
function sendWeixinPublic1(){
	document.getElementById("WeiXinPublic1").style.display="block";
}
function closeWechatPublic1(){
	document.getElementById('WeiXinPublic1').style.display = 'none';
}
function sendWeixinPublic2(){
	document.getElementById("WeiXinPublic2").style.display="block";
}
function closeWechatPublic2(){
	document.getElementById('WeiXinPublic2').style.display = 'none';
}

function weixinLogin(){
	var url = "/user/weixinLogin.do?random="+Math.round(Math.random()*100);
	jQuery.post(url,param,function (data){
		if(navigator.userAgent.indexOf("MSIE")>0) { 
			jQuery('#weixin_qrcode').qrcode({text:result.qecode,width:"150",height:"150",render:"table"}); 
		} else{
			jQuery('#weixin_qrcode').qrcode({text:result.qecode,width:"150",height:"150"}); 
		}
	});
}

// 设置邮件防钓鱼码
function setEmailVerify(){
	var emailVerify = document.getElementById("emailVerify").value;
	if(emailVerify==null || emailVerify==""){
		document.getElementById("totpCodeTips").innerHTML=get$("antiphishing3");;
		return ;
	}
	if(emailVerify.length < 1){
		document.getElementById("totpCodeTips").innerHTML=get$("antiphishing4");
		return ;
	}
	if(emailVerify.length > 20){
		document.getElementById("totpCodeTips").innerHTML=get$("antiphishing5");
		return ;
	}
	document.getElementById("totpCodeTips").innerHTML="";
	//点击按钮后让其置灰不可点并出现动态小点点
	waitingStation("submitBtn",get$("insubmiting"));
	
	var url = "/user/setEmailVerify.do?random="+Math.round(Math.random()*100);
	var param={emailVerify:emailVerify};
	jQuery.post(url,param,function(data){
		if(data==200){
			// 设置成功
			closeAuthenticatorLayer();
			var callback={okBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";},noBack:function(){window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";}};
			okcoinAlert(get$("antiphishing7"),null,callback);
		}else if(data==502 || data==503){
			document.getElementById("totpCodeTips").innerHTML=get$("antiphishing6");
		}else if(data==504){
			document.getElementById("totpCodeTips").innerHTML=get$("antiphishing9");
		}else{
			document.getElementById("totpCodeTips").innerHTML=get$("antiphishing8");
		}
		//恢复按钮让其可点击并去掉小点点
		cancelWaiting("submitBtn",get$("oksure"));
	});
}



function setNewEmailAddress(){
	var password = document.getElementById("loginPassword").value;
	var newEmail = document.getElementById("newEmailAddress").value;
	var desc = "";

	if(password == ""){
		document.getElementById("errorTips").innerHTML = get$("userindexjs54");
		return;
	}

	if(newEmail == ""){
		document.getElementById("errorTips").innerHTML = get$("userindexjs56");
		return;
	}

	var url = "/user/setNewEmailAddress.do?random="+Math.round(Math.random()*100);
	var param={password:password,newEmail:newEmail};
	jQuery.post(url,param,function(result){
		if(result == 0){
			jQuery("#refreshSingal").val(1);
			jQuery("#changeOldEmail").hide();
			jQuery("#changeOldEmailSuccess").show();
			jQuery("#dialog_content").css({
				"top":"40%",
				"width":"400px",
				"height":"300px",
				"margin-left":"-150px"
			});

		}else{
			if(result == -1){
                window.location.reload();
			}else if(result == -2){
                document.getElementById("errorTips").innerHTML = "您的账户拥有资产，请联系客服修改邮箱";
			}else if(result == -3){
                document.getElementById("errorTips").innerHTML = "参数不全";
            }else if(result == -4){
                document.getElementById("errorTips").innerHTML = get$("coincommonjs9");
            }else if(result == -5){
                document.getElementById("errorTips").innerHTML = "新邮箱与当前邮箱地址相同";
            }else if(result == -6){
                document.getElementById("errorTips").innerHTML = get$("userindexjs55");
            }else if(result == -7){
                document.getElementById("errorTips").innerHTML = get$("coincommonjs34");
            }else {
                document.getElementById("errorTips").innerHTML = "修改邮箱地址失败";
            }
		}
	});
}




